package org.nfIt.th02;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * ClossName:ProductGetter
 * Pakage:org.nfIt.th02
 * Description
 *
 * @Author L
 * @Create 2024/5/18 20:14
 * @Version 2023.1.3
 *
 * 抽奖商品案例
 *
 */
public class ProductGetter<T> {

    /**
     * 奖品
     */
    private T product;

    /**
     * 存储奖品
     */
    private List<T> productList = new ArrayList<>();

    /**
     * 获取奖品
     */
    public T getProducts(){
        Integer index = new Random().nextInt(productList.size());
        return  productList.get(index);
    }

    /**
     * 添加奖品
     */
    public void addProduct(T t){
         productList.add(t);
    }



}
